package com.ows.powercontrol;

import org.springframework.beans.factory.annotation.Value;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.boot.autoconfigure.condition.ConditionalOnBean;
import org.springframework.boot.web.servlet.ServletComponentScan;
import org.springframework.context.annotation.Bean;
import java.net.Socket;

@SpringBootApplication
@ServletComponentScan
public class PowercontrolApplication{
	public static void main(String[] args) {
		SpringApplication.run(PowercontrolApplication.class, args);
	}
	@Value("${port}")
	private int port ;
	@Value("${host}")
	private String host;


	@ConditionalOnBean(Socket.class)
	@Bean
	public Socket servcerSocket() {

		try {
			return new Socket(host,port);
		} catch (Exception e) {
			e.printStackTrace();
			return null;
		}
	}
}
